<?php
use \PsiFramework\Classes\Util\UI\Printer;
use \PsiFramework\Classes\Util\UI\HTML;
use \PsiFramework\Plugins\Form\Classes\Util\FormUtil;
use \PsiFramework\Plugins\Form\Classes\Util\Json\JsonForm;
use \PsiFramework\Classes\Util\Manager\ObjectManager;

import("Plugins.Form.Classes.Util.FormUtil");
import("Plugins.Form.Classes.Util.Json.JsonForm");
import("Classes.Util.Manager.ObjectManager");

$fieldType = $response->getAttribute("object");
$objectType = $response->getAttribute("objectType");

$jsonForm = null ;
if (!is_null($fieldType)) {
    $jsonForm = $fieldType->getStructure();
}
?>
<form
    class="editForm"
    method="POST"
    action="<?php Printer::display(HTML::linkHref('action=CMS.Save&type='.$objectType));?>"
    onsubmit="return validateFieldType()">
    <?php
    if (!is_null($fieldType)) {
    ?>
    <input
        type="hidden"
        name="id"
        value="<?php Printer::display($fieldType->getId()); ?>" />
    <input
        type="hidden"
        name="name"
        id="field_type_name"
        value="<?php Printer::display($fieldType->getName()); ?>" />
    <div class="label">
        <span class="titre"><?php Printer::display($fieldType->getName()); ?>
        </span>
    </div>
    <?php
    } else {
    ?>
    <div class="label">
        <span class="titre">Nom :</span>
        <input
            class="firstInput"
            type="text"
            name="name" id="field_type_name"
            value="<?php if (!is_null($fieldType)) Printer::display($fieldType->getName()); ?>"
            required="required" />
    </div>
    <?php
    }
    echo $jsonForm =
        ObjectManager::getInstance()->
            getPrimitiveObjectDaoInstance('JsonForm')->
            edit($jsonForm);
    ?>
    <input type="submit" value="OK" />
</form>
